package javao.cn.work.orc;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

@SpringBootApplication
@Slf4j
public class WorkOrcApplication {

	public static void main(String[] args) throws UnknownHostException {
		ConfigurableApplicationContext application = SpringApplication.run(WorkOrcApplication.class, args);
		Environment env = application.getEnvironment();
		String ip = InetAddress.getLocalHost().getHostAddress();
		String port = env.getProperty("server.port");
		String path = env.getProperty("server.servlet.context-path");
		String username = env.getProperty("knife4j.basic.username");
		String password = env.getProperty("knife4j.basic.password");
		if (path == null){
			path="/";
		}
		log.debug("\n----------------------------------------------------------\n\t" +
				"Application Osps is running! Access URLs:\n\t" +
				"Local(端口): \t\thttp://localhost:" + port + path + "\n\t" +
				"External(IP端口): \thttp://" + ip + ":" + port + path + "\n\t" +
				"在线日志监控: \thttp://" + ip + ":" + port + path  + "logging.html" +"\n\t"+
				"knife4j文档: \thttp://" + ip + ":" + port + path  +"doc.html"+"\n\t"+
				"knife4j文档账号:\t"+username+"\n\t"+
				"knife4j文档密码:\t"+password+"\n\t"+
				"----------------------------------------------------------");
	}

}
